package com.VitalFit.model.entity;

import cn.hutool.core.lang.Snowflake;
import cn.hutool.core.util.IdUtil;
import jakarta.persistence.*;
import lombok.Data;

@Entity
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name = "dtype", discriminatorType = DiscriminatorType.STRING)
@Data
@Table(name = "user", indexes = {
        @Index(name = "idx_dtype", columnList = "dtype")
})
public abstract class User {
    @Id
    private Long id;
    private String name;
    private String email;
    private String password;

    @Transient
    private String token;

    public User() {
        // 使用 Hutool 的 Snowflake 生成 ID
        Snowflake snowflake = IdUtil.getSnowflake(1, 1);
        this.id = snowflake.nextId();
    }


}